<style lang="less">
  @import './login.less';
</style>

<template>
  <div class="login">
    <span class="login-title"># 请开始你的工作..</span>
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" style="z-index: 99">
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"/>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
  import LoginForm from '_c/login-form'
  import {mapActions} from 'vuex'
  import Cookies from 'js-cookie'
  import {_ChildLoading} from "_libs/util";

  export default {
    components: {
      LoginForm
    },
    methods: {
      ...mapActions({
        handleLogin: 'system/user/handleLogin',
        getUserInfo: 'system/user/getUserInfo'
      }),
      handleSubmit({username, password}, loadingCb) {

        let res = this.handleLogin({username, password});

        _ChildLoading(res, () => {
          this.$router.push({
            name: 'home'
          })
          this.getUserInfo().then(() => {
          })
        }, loadingCb)

      }
    },
    created() {
      Cookies.remove('modules')
      Cookies.remove('functions')
    }
  }
</script>

<style>

</style>
